package com.lagou.interceptor;

import com.lagou.util.TransportIPUtil;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author bobcheng
 * @date 2020/6/15
 */
public class IPInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String ip = request.getRemoteAddr();
        TransportIPUtil.setIp(ip);
        return true;
    }

}
